The Read function read a line from the file chosen by the set input function, strips the newline character and returns the resulting string. If the input is stdin, the user will be prompted by a ? and the program will stop until a non-null string is entered. This is most likely to be used in macros requiring some input during run time. The Read() function can be used to read numbers with the help of scan(). See the example below.
Read can also be used to build vectors by taking one every n points. This can be done by two imbedded for loops.
Note: The newline character is not passed to the string.
# Read a string from stdin (the default) set input stdin let String = Read() # How to get a value out of a string: equivalent to vread() let value = scan(Read(), "\%lf") \eq # How to skip lines in a file # Read say file project/numbers.data set input project/numbers.data cmode for (i=1; i<=top; i++) { Line = Read() # Read one line X[i] = scan(Line, "%lf"); # get first column Y[i] = scan(Line, "%*lf %*lf %lf"); # get third column for (j=1; j<n; j++) { Line = Read() # Read n-1 lines } } fmode set input stdin
set input, math function scan, string functions, $